package com.pilipili.zeus.eduService.service.impl;

import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pilipili.zeus.eduService.entity.EduCourseDescription;
import com.pilipili.zeus.eduService.entity.excel.DescriptionExcelData;
import com.pilipili.zeus.eduService.listener.DescriptionListener;
import com.pilipili.zeus.eduService.mapper.EduCourseDescriptionMapper;
import com.pilipili.zeus.eduService.service.EduCourseDescriptionService;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;

/**
 * 番剧简介 服务实现类
 *
 * @author Unlimited_Blade_Works
 * @since 2021-05-26
 */
@Service
public class EduCourseDescriptionServiceImpl extends ServiceImpl<EduCourseDescriptionMapper, EduCourseDescription> implements EduCourseDescriptionService {

    @Override
    public void saveCourseDescriptionDataByExcel(MultipartFile file, EduCourseDescriptionService descriptionService) {
        try {
            //文件输入流,调用方法读取Excel
            InputStream stream = file.getInputStream();
            EasyExcel.read(stream, DescriptionExcelData.class,new DescriptionListener(descriptionService)).sheet().doRead();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
